package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Class;
import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.mapper.ClassMapper;
import com.neuedu.studentmanage.service.ClassService;

@Service
@Transactional
public class ClassServiceImpl implements ClassService {

	@Autowired
	private ClassMapper classMapper;

	@Override
	public List<Class> findListByPager(Pager<Class> pager) {

		return classMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Class> pager) {

		return classMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Class object) {
		Result result = new Result(false, "新增班级信息失败");
		boolean ret = classMapper.add(object);
		if (ret) {
			result = new Result(true, "新增班级信息成功");
		}
		return result;
	}

	@Override
	public Result edit(Class object) {
		Result result = new Result(false, "修改班级信息失败");
		boolean ret = classMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改班级信息成功");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Class> ids) {
		Result result = new Result(false, "删除班级信息失败");
		boolean ret = classMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除班级信息成功");
		}
		return result;
	}

	@Override
	public List<Class> findAll() {

		return classMapper.findAll();
	}

}
